//
//  RecommendHandler.m
//  Travel_M_Travel
//
//  Created by Sun on 15/3/27.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "RecommendHandler.h"

@implementation RecommendHandler

+ (void)getDataWithUrl : (NSString *)str completion : (void (^)(NSDictionary *))block
{
    // 本地存储
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *path = [NSString stringWithFormat:@"%@/%ld.TMT", docPath, [str hash]];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        BOOL result = [NSKeyedArchiver archiveRootObject:responseObject toFile:path];
        NSLog(@"存储成功: %d", result);
        NSLog(@"%@", path);
        block (responseObject);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];

}


@end
